#ifndef NR_USER_H
#define NR_USER_H

/**
 * @file nr_user.h
 * @brief User
 */

#include "nr_object.h"
#include "nr_role.h"

/**
 * This is the nr_user's role name list
 * A user can play as several roles 
 */
typedef QSet<QString> nr_user_roles;

/**
 * This class define the user
 *
 * Client or server should use a user when login
 * user can play as several roles
 */
class nr_user : public nr_object
{
public:
    /**
     * Default constructor
     */
    nr_user(const QString& name) 
        : m_name(name) 
        , m_enable(true)
        , m_forever(true)
    {
    }
    
    /**
     * Destructor
     */
    ~nr_user() { }

    /**
     * The user's name, user's name should not changed after created
     */
    QString name() { return m_name; }

    /**
     * Get or set the user's password
     */
    QString& password();

    /**
     * Get or set user is enabled or not
     */
    bool& enable();

    /**
     * Get or set the user's expire date
     */
    QDateTime& expire() { return m_expire; }

    /**
     * Get or set the user's forever flag, 
     * the forever user will not expire
     */
    bool& is_forever() { return m_forever; }

    /**
     * Get the role list,
     * Add or remove the user's role
     */
    nr_user_roles& roles() { return m_user_roles; }

private:
    QString m_name;
    QDateTime m_expire;
    bool m_enable;
    bool m_forever;
    nr_user_roles m_user_roles;
};

/**
 * This is the nr_user list
 */
typedef QHash<QString, nr_user*> nr_users;

#endif // NR_USER_H
